<?php 

function laporan_riwayat_kerja(){ 

	$fields =   my_get_data_by_id('riwayat_kerja','no_mcu', $_SESSION['no_mcu']); 
	 $view = report_header( "edit kerja" , "edit-kerja"  );
	if(!$fields):
		$fields['nama_perusahaan']= $fields['jabatan']= $fields['tahun'] = $fields['devisi'] = "- ";
		$fields['berdebu'] = $fields['bahan_kimia'] =$fields['cairan_berbahaya'] =$fields['radiasi']="- ";
		$fields['asap'] = $fields['fume'] = $fields['mengelola_makanan'] = $fields['operator_alat_berat']=
		$fields['operator_alat_berat'] = $fields['getaran_alat'] =$fields['bising']=$fields['suhu_sangat_panas']=
		$fields['listrik'] = $fields['darah_cairan_serum'] = $fields['kantoran'] = $fields['ketajaman_lihat'] =
		$fields['suhu_sangat_dingin']= $fields['bekerja_ketinggian']=$fields['bising']="- ";
		
	
	endif; 
	
	$view .= form_field_report( ': '.ucfirst($fields['nama_perusahaan'] ), "Perusahaan" ,  "#FFFFFF"  );
 	$view .= form_field_report( ': '.$fields['jabatan'], "Sebagai" ,  "#FFFFFF"  );
	 
	$view .= form_field_report( ': '.$fields['tahun'] .' s/d '.$fields['sampai']  , "Tahun" ,  "#FFFFFF"  );
	 
	$view .= form_field_report( ': '.$fields['devisi'], "Devisi" ,  "#FFFFFF"  );
	
	$view .='<tr><td colspan="2" class="detailinfo">&nbsp;
	</td></tr>';
	$view .='<tr><td colspan="2" class="detailinfo"><u>PEKERJAAN BERHIBUNGAN DENGAN :</u></td></tr>';
 
	$view .= form_field_report( '<i>Jenis:</i> '.ucfirst($fields['berdebu']), "Berdebu" ,  "#FFFFFF"  );
	 
	$view .= form_field_report( '<i>Jenis:</i> '. ucfirst($fields['bahan_kimia'] ), "Bahan kimia berbahaya" ,  "#FFFFFF"  );
 
	$view .= form_field_report( '<i>Jenis:</i> '.ucfirst($fields['cairan_berbahaya']), "Cairan berbahaya" ,  "#FFFFFF"  );
	 
	$view .= form_field_report( '<i>Jenis:</i> '.ucfirst($fields['radiasi']), "Radiasi" ,  "#FFFFFF"  );	 
	$view .= form_field_report( '<i>Jenis:</i> '.ucfirst($fields['asap'] ) , "Asap" ,  "#FFFFFF"  );
 
	$view .= form_field_report( '<i>Jenis:</i>  '.ucfirst($fields['fume']), "Fume" ,  "#FFFFFF"  );	
 
	$view .= form_field_report( '<i>Sebagai:</i> '.ucfirst($fields['mengelola_makanan'] ), "Mengelola makanan" ,  "#FFFFFF"  );	
 
	$view .= form_field_report( '<i>Jenis:</i> '.ucfirst($fields['operator_alat_berat']) , "Operator alat berat " ,  "#FFFFFF"  );	
 
	$view .= form_field_report( '<i>Jenis:</i> '.$fields['getaran_alat'] , "Getaran alat " ,  "#FFFFFF"  );
 
	$view .= form_field_report(  ': '.$fields['suhu_sangat_panas'] .' &deg;C', "Suhu sangat panas" ,  "#FFFFFF"  );
 
	$view .= form_field_report(  ': '.$fields['suhu_sangat_dingin'].' &deg;C' , "Suhu sangat dingin" ,  "#FFFFFF"  );
	 
	$view .= form_field_report(  ': '.$fields['bekerja_ketinggian']  .' meter' , "Bekerja pada ketinggian" ,  "#FFFFFF"  );
	 
	$view .= form_field_report(  ': '.$fields['bising'].' +/- dB' , "Bising" ,  "#FFFFFF"  );
	 
	$view .= form_field_report(  '<i>Keterangan:</i> '.$fields['ketajaman_lihat']   , "Butuh ketajaman penglihatan" ,  "#FFFFFF"  );
  
	$view .= form_field_report(  '<i>Keterangan:</i> '.$fields['kantoran'] , "Bekerja kantoran" ,  "#FFFFFF"  );
	
 
	$view .= form_field_report(  '<i>Jenis:</i> '.$fields['darah_cairan_serum']   , "Berhubungan dengan <br/>darah/cairan tubuh/serum" ,  "#FFFFFF"  );
	
	 
	$view .= form_field_report(  ': '.$fields['listrik'].' Volt/Watt'  , "Berhubungan dengan  listrik" ,  "#FFFFFF"  );
 
	$view .= report_footer( );
	return $view;
	
}
function laporan_riwayat_keluarga_cetak( ){
	$query_opsi = "SELECT * FROM jawaban_survey WHERE group_jawaban_id = 1 ";
	$result_opsi = my_query($query_opsi);
	$header = array();
	$header[' '] =array('style'=>'border-bottom:2px solid;width:5%' ) ;
	$header['penyakit'] =array('style'=>'border-bottom:2px solid;width:51%') ;
	$header['keterangan'] =array('style'=>'border-bottom:2px solid;width:44%'  ) ;
	$fd = array();
	while( $row_opsi = my_fetch_array($result_opsi) ){
	$fd[$row_opsi['jawaban_id']] = $row_opsi['jawaban'];
	//$header[$row_opsi['jawaban']] =array('style'=>'border-bottom:2px solid','width'=>'7%') ;
	} 
	$result = my_query('SELECT * FROM `pertanyaan_survey` WHERE group_jawaban_id =1'); 
	$row = array(); 
	$i = 1;
	while( $ey = my_fetch_array($result) ){

		$trow =  array('#'=>position_text_align( $i ,'center'),'penyakit'=>$ey['pertanyaan'] ) ;
		$xrow ='';
		foreach( $fd  as $f=>$d ){   
			$query_u = "SELECT * FROM `hasil_survey` a INNER JOIN jawaban_survey b ON a.jawaban_id =b.jawaban_id
						WHERE a.pertanyaan_id = {$ey['pertanyaan_id']} 
						AND a.jawaban_id = {$f}
						AND a.no_mcu = '{$_SESSION['no_mcu']}' "; 
			$result_u =my_query($query_u);
			if( my_num_rows($result_u) > 0 ){ 
				$trp=my_fetch_array($result_u);
				$xrow   .= $trp['jawaban'] .', '  ;
			} 
		}  
		$row[] = array(
			'nourut' =>  $i ,
			'tanya' => 			$ey['pertanyaan'], 
			'keterangan' => ( strlen($xrow) > 0 ? trim($xrow , ', ' ) : '-')
		);
		$i++;
	} 	
	$datas = table_cetak_rows($row);
	$content = table_cetak_builder($header , $datas ,  8   );
	return   $content ;
}

function laporan_riwayat_ask_list(){ 
  
$query_opsi = "SELECT * FROM jawaban_survey WHERE group_jawaban_id = 19 ";
$result_opsi = my_query($query_opsi);
$header = array(  );
$header[' '] =array('style'=>'border-bottom:2px solid;width:5%') ; 
$header['penyakit'] =array('style'=>'border-bottom:2px solid;width:50%') ;
$header['tahun'] =array('style'=>'border-bottom:2px solid;width:10%') ;
$header['keterangan'] =array('style'=>'border-bottom:2px solid;width;35%') ;
$fd = array();
while( $row_opsi = my_fetch_array($result_opsi) ){
$fd[$row_opsi['jawaban_id']] = $row_opsi['jawaban'];
} 
$result = my_query('SELECT * FROM `pertanyaan_survey` WHERE group_jawaban_id =19 '); 
$row = array(); 
$i = 1;
while( $ey = my_fetch_array($result) ){
	$query_u = "SELECT * FROM `hasil_survey` 
						WHERE pertanyaan_id = {$ey['pertanyaan_id']}  
								AND no_mcu = '{$_SESSION['no_mcu']}'";
	$result_u =my_query($query_u);
	if( my_num_rows($result_u) > 0 ){
		if($trow = my_fetch_array($result_u)){
			$yesformvalue = '';
			$yearformvalue=	trim($trow['catatan']);
			$diobativalue = $trow['jawaban_id'];
		}
	}else{
			$yesformvalue = '-';
			$yearformvalue='-';
			$diobativalue='-';
	}
     $trow =  array('#'=>position_text_align( $i ,'center'),'s'=>$formyes ,'penyakit'=>$ey['pertanyaan'] ,'tahun'=>$formtahun) ;

	foreach( $fd  as $f=>$d ){  
		if($diobativalue == $f){
			$formnya = ' Diobati';
		}else{
			$formnya = 'Tidak diobati';
		} 
	} 
	if($yearformvalue=='-')$formnya='-';
	$row[] = array( 
			'nourut' => $i , 
			'penyakit' => 		 	$ey['pertanyaan'],  
			'tahun_penyakit' => $yearformvalue,  
			'ket_penyakit' =>  $formnya 
	); 
	$i++;
} 	
$datas = table_cetak_rows($row);
$content = table_cetak_builder($header , $datas ,  8   );
 
return   $content ;
 
}


function laporan_gejala_ask_list(){ 
  
$header = array(  );
$header[' '] =array('style'=>'border-bottom:2px solid;width:5%') ;
$header['Gejala'] =array('style'=>'border-bottom:2px solid;width:55%') ; 
$header['Keterangan'] =array('style'=>'border-bottom:2px solid;width:40%') ;

$result = my_query('SELECT * FROM `pertanyaan_survey` a 
INNER JOIN jawaban_survey b ON b.group_jawaban_id=a.group_jawaban_id
				WHERE a.group_jawaban_id =2 AND a.group_id = 2'); 
$row = array(); 
$i = 1;
while( $ey = my_fetch_array($result) ){
	
	$checked_query = "SELECT * FROM hasil_survey WHERE jawaban_id ={$ey['jawaban_id']} AND pertanyaan_id={$ey['pertanyaan_id']} AND no_mcu = '{$_SESSION['no_mcu']}'";
	$result_query = my_query($checked_query);
	$checked =  (my_num_rows($result_query) > 0  ) ? ' Ya ' : "-"  ; 
	$row[] =  array('nourut'=> $i , 
	'gejala'=> $ey['pertanyaan'],
	'ket_gejala'=>  $checked  ) ;
	$i++;
} 	
$datas = table_cetak_rows($row);
$content = table_cetak_builder($header , $datas ,  5  );
 
return  $content ;
  
}


function laporan_nyeri_dada(){
	$data_online = my_get_data_by_id('nyeri_dada','no_mcu',$_SESSION['no_mcu']); 
	 
	if(is_null($data_online['nyeri_dada_buru_buru']))return "Data belum ada"; 
	$jawaban_nyeri_dada_buru_buru = my_get_data_by_id('jawaban_survey' , 'jawaban_id' , $data_online['nyeri_dada_buru_buru']);
	$jawaban_aktifitas_fisik = my_get_data_by_id('jawaban_survey' , 'jawaban_id' , $data_online['aktifitas_fisik']);
	$view .='Nyeri dada terasa jika melakukan aktifitas yang terburu-buru? <u>'.$jawaban_nyeri_dada_buru_buru['jawaban'].'</u><br />';
	$view .= 'Apa yang terjadi jika berhenti dari aktifitas fisik? <u>'.$jawaban_aktifitas_fisik['jawaban'].'</u><br/>';
	if( 
		($data_online['bahu']=='1') 
		OR ($data_online['dinding']=='1') 
		OR($data_online['bawah']=='1') 
		OR ($data_online['atas']=='1') 
	):
		$view .= ' 
			<b> Nyeri dirasakan pada:</b><br>';
		if($data_online['atas']=='1')
		$view .= '- Bagian atas / tengah tulang dada<br> ';
		
		if($data_online['bawah']=='1')
		$view .= '- Bagian bawah tulang dada<br> ';
		
		if($data_online['dinding']=='1')
		$view .= '- Dinding dada<br> ';
		
		if($data_online['bahu']=='1')
		$view .= '- Daerah bahu / leher kiri<br> ';
		 
	endif;
	
	
	if($data_online['lebih_10_menit']=='1')
	$view .= 'Nyeri dada berlangsung lebih dari 10 menit<br> ';
	
	if($data_online['dada_menjalar']=='1')
	$view .= 'Nyeri dada menjalar ketempat lain<br> ';
	
	if(trim($data_online['keluhan_lain']) <> ''){
	$view .= '<br>Keluhan yang lain, harap di isi<br>';
	$view .= '<i>'.nl2br($data_online['keluhan_lain']).'</i>';
	}
	return ' <div class="main" style="line-height:24px;">'.$view.'</div><br>';
}


function laporan_hambatan_aktifitas_fisik(){
	$header = array(  );
	$header[' '] =array('style'=>'border-bottom:2px solid;width:5%') ;
	$header['pertanyaan'] =array('style'=>'border-bottom:2px solid;width:65%') ;
	$header['jawaban'] =array('style'=>'border-bottom:2px solid;width:30%') ;
	$query_opsi = "SELECT * FROM pertanyaan_survey a INNER JOIN hasil_survey b
						ON a.pertanyaan_id = b.pertanyaan_id
						WHERE group_jawaban_id = 6 ";
	$result_opsi = my_query($query_opsi);
	$i=1;
	if( my_num_rows($result_opsi) == 0 )return "Belum ada data";
	while( $ey = my_fetch_array($result_opsi) ){
	
	$jawaban = my_get_data_by_id('jawaban_survey','jawaban_id',$ey['jawaban_id']); 
	$row[] =  array(
			'nourut'=> $i , 
			'hambatan_aktifitas'=> $ey['pertanyaan'], 
			'jawaban_hambatan'=> $jawaban['jawaban']  ) ;
	$i++;
	}
	
$datas = table_cetak_rows($row);
$content = table_cetak_builder($header , $datas ,  5  );
	return $content;
}


function laporan_aktifitas_fisik(){
	$ansjumlah =0;
	$query_check_jumlah = "SELECT jumlah_hari FROM hasil_survey_extend WHERE no_mcu ='{$_SESSION['no_mcu']}' ";
	$result_check_jumlah = my_query($query_check_jumlah);
	if($row_check_jumlah = my_fetch_array($result_check_jumlah) ){
		$ansjumlah = $row_check_jumlah['jumlah_hari'];
	}
$view = "<div class=\"main\">Latihan aeroik dalam seminggu :<br>";
$view .= ($ansjumlah == 0) ? "Tidak pernah" : $ansjumlah ." hari dalam seminggu";
if($ansjumlah > 0){
	$view .= '</div><br>';
	
	$query ="
		SELECT * FROM `hasil_survey` a
		INNER JOIN `pertanyaan_survey` b ON a.pertanyaan_id = b.pertanyaan_id
		WHERE a.no_mcu= '{$_SESSION['no_mcu']}' AND b.group_id =6 ORDER BY b.pertanyaan_id ASC
	";
	$result = my_query($query);
	if( my_num_rows($result) > 0 ){ 
	$view .= 'Jenis aktifitas fisik:<ul class="main">';
	$tview='';
	while($row = my_fetch_array($result)){
		$view .= '<li>'.$row['pertanyaan']."</li>";
	} 
	$view .= trim( $tview,", ");
	$view .='</ul>';
	} 
}else{
	return "Belum ada data";
}

return $view;
}

function laporan_kebiasaan_makan(){
$extends = my_get_data_by_id("hasil_survey_extend" , "no_mcu" , $_SESSION['no_mcu']);
$view ="";
$querysp = "SELECT * FROM pertanyaan_survey WHERE group_id = 7";	
$resu = my_query($querysp);
	while($yp = my_fetch_array($resu)):
	$query = "SELECT * FROM `pertanyaan_survey` a 
				INNER JOIN jawaban_survey b ON b.group_jawaban_id=a.group_jawaban_id
				WHERE a.pertanyaan_id ={$yp['pertanyaan_id']} AND a.group_jawaban_id = {$yp['group_jawaban_id']} AND a.group_id = 7";
  
	$res = my_query($query );		
if(my_num_rows($res) > 0):	
	if( $row = my_fetch_array($res) ){
		$perta = $row['pertanyaan'];
	 	$perta = str_replace('<center>','<!-- ', $perta);
		$perta = str_replace('</center>','//--> ', $perta);
	
		$view .= $perta.'<br>';
		if(trim($row['remark']) <> '' ){
		$view .= $row['remark'].'<br>';
		}
		$checked_query = "SELECT jawaban_id FROM hasil_survey WHERE   pertanyaan_id={$row['pertanyaan_id']} AND no_mcu = '{$_SESSION['no_mcu']}'";
		$result_query = my_query($checked_query);
		$jawaban_user  =0;
		if($row_checked = my_fetch_array($result_query )){
			$jawaban_user = $row_checked['jawaban_id'];
		}
		
	} 
	$jawaban = my_get_data_by_id('jawaban_survey','jawaban_id',$jawaban_user);
	$view .=   '<i>'.$jawaban['jawaban'];
	
	if($yp['pertanyaan_id'] == "103"){
		$view .=', <b>Jenis:</b> '.$extends['penenang'];
	}
	if($yp['pertanyaan_id'] == "104"){
		$vrokok = array(
			1=>'&lt; 1 bungkus perhari',
			2=>'2 - 5 bungkus perhari',
			3=>'&gt; 5 bungkus perhari',
		);
		$view .=', '.$vrokok[$extends['rokok']];
	}
	$view .='</i> <br> <br>';
endif;
	endwhile;
	   
	return  $view ;
}


function stress_report(){ 
	$query = "SELECT * FROM pertanyaan_survey WHERE group_id = 10 AND group_jawaban_id =22";
	$result = my_query($query);
	if(my_num_rows($result) > 0 ):
	$view ="";
	while($row =my_fetch_array($result)){
		$view .= $row['pertanyaan'].'<br>'; 
		$dk = "SELECT * FROM hasil_survey a 
			INNER JOIN jawaban_survey b ON a.jawaban_id = b.jawaban_id
			WHERE a.no_mcu='{$_SESSION['no_mcu']}' 
			AND a.pertanyaan_id={$row['pertanyaan_id']}";
		$resultsa =my_query($dk);
		if($eu = my_fetch_array($resultsa)){
			$view .= '- '.$eu['jawaban'] .'<br> ';
		}
	}
	 
	endif;
	$view .='<b>Pernyataan  anda:</b> <br/>';
	$query = "SELECT * FROM pertanyaan_survey WHERE group_id = 10 AND group_jawaban_id = 2";
	$result = my_query($query);
	if(my_num_rows($result) > 0 ):
	while($yp =my_fetch_array($result)){
		$view .= '' ;
		$ansquery   = "SELECT * FROM hasil_survey a 
			INNER JOIN pertanyaan_survey b ON a.pertanyaan_id = b.pertanyaan_id
			WHERE a.no_mcu='{$_SESSION['no_mcu']}' 
			AND a.pertanyaan_id={$yp['pertanyaan_id']}"; 
		$ansresult = my_query($ansquery);
		if(  my_num_rows($ansresult) >0 ){ 
 		
			$view .='- '.$yp['pertanyaan'].'<br>'; 
		}
		 
		
	}
	endif;
	return  '<div class="main" style="line-height:24px">'.$view.'</div><br><br>';
}

function laporan_perasaan_akhir(){ 
$header = array(  );
$header[' '] =array('style'=>'border-bottom:2px solid;width:5%') ;
$header['Perasaan'] =array('style'=>'border-bottom:2px solid;width:55%') ; 
$header['Keterangan'] =array('style'=>'border-bottom:2px solid;width:40%') ;
	$query = "SELECT * FROM `pertanyaan_survey` a  	
				INNER JOIN hasil_survey c ON a.pertanyaan_id=c.pertanyaan_id 
				WHERE   c.no_mcu ='{$_SESSION['no_mcu']}'
				AND a.group_id = 8 GROUP BY a.pertanyaan_id";
		$i=1; 
	$res = my_query($query);
	if(my_num_rows($res) == 0)return "Data belum di isikan";

	$datas = array(); 
	$readview ="";
	while( $rowx = my_fetch_array($res) ){
		$jawaban = my_get_data_by_id('jawaban_survey','jawaban_id',$rowx['jawaban_id']); 
		if($rowx['group_jawaban_id'] ==  18 ): 
			$row[] =  array(
			'nourut'=>  $i ,
			'perasaan'=> $rowx['pertanyaan'], 
			'ket_perasaan'=> $jawaban['jawaban']  ) ;
		$i++;
		else:
			$readview .=$rowx['pertanyaan']." <b>".$jawaban['jawaban']."</b><br>";
		endif;
	}
 
$datas = table_cetak_rows($row);
$content = table_cetak_builder($header , $datas ,  5  );

return $content.$readview."<br>" ;
}

function laporan_hobby(){ 
  
$header = array(  );
$header[' '] =array('style'=>'border-bottom:2px solid;width:5%') ;
$header['Hobby'] =array('style'=>'border-bottom:2px solid;width:55%') ; 
$header['Keterangan'] =array('style'=>'border-bottom:2px solid;width:40%') ;

$result = my_query('SELECT * FROM `pertanyaan_survey` a 
INNER JOIN jawaban_survey b ON b.group_jawaban_id=a.group_jawaban_id
				WHERE a.group_jawaban_id =2 AND a.group_id = 9'); 
$row = array(); 
$i = 1;
while( $ey = my_fetch_array($result) ){
	
	$checked_query = "SELECT * FROM hasil_survey WHERE 
		 pertanyaan_id={$ey['pertanyaan_id']} 
		AND no_mcu = '{$_SESSION['no_mcu']}'";
 
	$result_query = my_query($checked_query);
	$checked =  (my_num_rows($result_query) > 0  ) ? ' Ya ' : "-"  ;  
	$row[] =  array('nourut'=>  $i , 
	'perasaan'=> $ey['pertanyaan'], 
	'ket_perasaan'=> $checked   ) ;
	$i++;
} 	
$datas = table_cetak_rows($row);
$content = table_cetak_builder($header , $datas ,  5  );
 
return  $content ;
  
}

function laporan_kesimpulan_klinis(){
	$data = my_get_data_by_id('kesimpulan_klinis','no_mcu',$_SESSION['no_mcu'] );
	$view = '<u><b>'.strtoupper($data['kelainan_fisik']).'</b></u>';
	$kesimpulan_id =  $data ? $data['kesimpulan_id'] :0;
	$list_kelainan = "SELECT kelainan_fisik FROM kesimpulan_klinis_kelainan WHERE kesimpulan_id = {$kesimpulan_id} GROUP BY kelainan_fisik";
	$result = my_query($list_kelainan);
	if(my_num_rows($result) > 0){
		$view .='<ul>';
		while($riow = my_fetch_array($result)){
			$view .= '<li>'. $riow['kelainan_fisik'].'</li>';
		}
		$view .='</ul>';
	}
	$view .= '<br><u><b>RESIKO MENDERITA PENYAKIT/GANGGUAN</b></u>';
	
	 
	$header = array(  );
	$header[' '] =array('style'=>'border-bottom:2px solid;width:5%') ;
	$header['Penyakit | Kelainan'] =array('style'=>'border-bottom:2px solid;width:60%') ; 
	$header['rendah'] =array('style'=>'border-bottom:2px solid;width:15%') ;
	$header['sedang'] =array('style'=>'border-bottom:2px solid;width:15%') ;
	$header['tinggi'] =array('style'=>'border-bottom:2px solid;width:15%') ;
	
	$row = array(); 
	$i = 1;
	$query = "SELECT * FROM saran_resiko WHERE `group` = 'resiko' AND `status` = 'active' ";
	$result = my_query($query);
	while( $ey = my_fetch_array($result) ){
		
		$resiko_p = my_get_data_by_id('kesimpulan_resiko','saran_resiko_id',$ey['saran_id']); 
		$rs2 = ($resiko_p['value'] == "rendah") ? 'Ya': "-";
		$rs3 = ($resiko_p['value'] == "sedang") ? 'Ya': "-";
		$rs4 = ($resiko_p['value'] == "tinggi") ? 'Ya': "-";
		$row[] =  array('nourut'=>  $i , 
		'penyakit'=> $ey['label'],  
		'aaa'=>  $rs2 ,  
		'aab'=>   $rs3 ,
		'aac'=>   $rs4  );
		$i++;
	}	
	$datas = table_cetak_rows($row);
	$view .= table_cetak_builder($header , $datas ,  5  );
	
	$view .= ' <u><b>SARAN KLINIS</b></u>';
	$q = "SELECT * FROM saran_klinis a 
	INNER JOIN saran_klinis_kesehatan b ON a.saran_klinis_id=b.saran_klinis_id
	INNER JOIN saran_resiko c ON b.saran_resiko_id=c.saran_id
	WHERE a.no_mcu='{$_SESSION['no_mcu']}' GROUP BY c.saran_id";
	$res2 = my_query($q);
	if(my_num_rows($res2) > 0){
		$view .='<ul>';
		while($riow2 = my_fetch_array($res2)){
			$view .= '<li>'. $riow2['label'].'</li>';
		}
		$view .='</ul>';
	}
	return $view;
}

function kesimpulan_okupasi(){
$k =  my_get_data_by_id( 'saran_okupasi_jawaban','no_mcu',$_SESSION['no_mcu'] );

$datas = my_get_data_by_id( 'rekomendasi','no_mcu',$_SESSION['no_mcu'] );
	$view = '<b>Rekomendasi kedokteran okupasi:</b><br>'.$k['kemungkinan_kerja'].'<br> ';
	
	
	$view .= '<br> <b>Saran kedokteran okupasi:</b><br>';
	if($datas['dapat_bekerja'] =='yes')	
	$view .= ' Dapat bekerja seperti biasa<br>';
	if($datas['tidak_dapat_bekerja'] =='yes')
	$view .= ' Tidak dapat bekerja seperti biasa, perlu penyesuaian<br> '; 
	if($datas['perlu'] =='yes')
	$view .= '
	 Bila perlu, calon karyawan diberi kesempatan berobat 14 hari,
	kemudian periksa kembali<br>';  
$hasil =  my_get_data_by_id( 'saran_okupasi_hasil','no_mcu',$_SESSION['no_mcu'] );	
	if($hasil['jadwal_periksa'] <> '')
	$view .='Ulangi pemeriksaan laboratorium '.$hasil['jadwal_periksa'].' lag<br>';
	if($hasil['jadwal_periksa_kesehatan'] <> '')
	$view .='Ulangi pemeriksaan kesehatan '.$hasil['jadwal_periksa_kesehatan'].' lagi<br>';
	return $view;
	$view .= ' <br><br><br><u><b>Saran kedokteran okupasi</b></u>';
	$q = "
	SELECT * FROM saran_okupasi_hasil a 
	INNER JOIN saran_okupasi_kesehatan b
	ON a.saran_okupasi_hasil_id=b.saran_okupasi_hasil_id
	INNER JOIN saran_okupasi c ON b.saran_okupasi_id= c.saran_okupasi_id
	WHERE a.no_mcu ='{$_SESSION['no_mcu']}' GROUP BY b.saran_okupasi_id
	";
	$ry=my_query($q );
	if(my_num_rows($ry) > 0){
		$view .='<ul>';
		while( $gt = my_fetch_array($ry) ){
			$view .='<li>'.$gt['saran'].'</li>';
		}
		$view .='</ul>';
	}
	return $view;
}
?>
<style type="text/css">
<!--
	table.page_header {width: 100%; border: none; background-color: #DDDDFF; border-bottom: solid 1mm #AAAADD; padding: 2mm }
	table.page_footer {width: 100%; border: none; background-color: #DDDDFF; border-top: solid 1mm #AAAADD; padding: 2mm}
	table.profil {width: 100%; border: none;  padding: 2mm}
	div.note {border: solid 1mm #DDDDDD;background-color: #EEEEEE; padding: 2mm; border-radius: 2mm; width: 100%; }
	ul.main { width: 95%; list-style-type: square; }
	ul.main li { padding-bottom: 2mm; }
	h1 { text-align: center; font-size: 20mm}
	h2 { text-align: center; font-size: 16mm}
	h3 { text-align: center; font-size: 14mm}
	table.content_view{width: 100%; border: none; border-bottom: solid 1mm #AAAADD; padding: 6mm}
	td.nourut{width:5%; text-align:center;}
	td.penyakit{width:50%; text-align:left;}
	td.tahun_penyakit{width:15%; text-align:center;}
	td.ket_penyakit{width:35%; text-align:left;}
	td.perasaan{width:55%; text-align:left;}
	td.ket_perasaan{width:40%; text-align:left;}
	table.pade_detail{width: 100%; border: none;  padding: 2mm}
	td.detailinfo{width:65%; text-align:left;height:30px;}
	td.detaillabel{width:35%; text-align:left;height:30px;}
-->
</style>
<?php  
$datas = my_get_data_by_id('peserta_mcu','no_mcu',$_SESSION['no_mcu']);
?>
<page backtop="14mm" backbottom="14mm" backleft="10mm" backright="10mm" style="font-size: 12pt">
	<page_header>
		<table class="page_header">
			<tr>
				<td style="width: 50%; text-align: left">
					Nama : <?php echo $datas['nama_mcu'];?>
				</td>
				<td style="width: 50%; text-align: right">
					Tanggal cetak : <?php echo date("d-m-Y"); ?> 
				</td>
			</tr>
		</table>
	</page_header>
	<page_footer>
		<table class="page_footer">
			<tr>
				<td style="width: 33%; text-align: left;">
					RS Krakatau Medika
				</td>
				<td style="width: 34%; text-align: center">
					page [[page_cu]]/[[page_nb]]
				</td>
				<td style="width: 33%; text-align: right">
					LAPORAN MEDICAL CHECK UP
				</td>
			</tr>
		</table>
	</page_footer>
	<bookmark title="Halaman muka" level="0" ></bookmark>	
	<br><br><br><br><br><br><br><br>
	<h2>LAPORAN</h2>
	<h2>MEDICAL CHECK UP</h2> 
	<br> 
	<div style="text-align: center; width: 100%;">
		<br>
		<img src="<?php echo MY_COMPONENT_PATH.'/report/exemples/';?>res/logo_rskm.jpg" alt="Logo HTML2PDF" style="width:260px">
		<br>
	</div>
	<br><br><br><br><br> 
	<div class="note"> 
	<table class="profil">
			<tr>
				<td style="width: 25%; text-align: left; height : 21px">
					<b>Nama </b>  
				</td>
				<td style="width: 25%; text-align: left"> 
				<b>: </b><?php  echo $datas['nama_mcu'] ;?>
				</td>
			</tr>
			<tr>
				<td style="width: 25%; text-align: left; height : 21px">
					<b>Usia </b>  
				</td>
				<td style="width: 25%; text-align: left"> 
				<b>: </b><?php echo ( date('Y') - date('Y' , strtotime($datas['tanggal_lahir']." 00:00:00") ) );?> tahun
				</td>
			</tr>
			<tr>
				<td style="width: 30%; text-align: left; height : 21px">
					<b>Alamat </b>  
				</td>
				<td style="width: 30%; text-align: left"> 
				<b>: </b><?php echo $datas['alamat'];?>
				</td>
			</tr>
			 
		</table>
		
	</div>
	<br><br><br><br><br> 
	<div style="text-align: center; width: 100%; font-size: 24px;">
		Rumah Sakit Krakatau Medika<br>
		<span style="font-size:18px">Jl. Semang Raya Cilegon, 42435<br>Telepon : (0254) 396 333 , Fax : (0254) 396 333</span>
	</div>
</page>
<page pageset="old">
	<bookmark title="Kata pengantar" level="0" ></bookmark> 
	<b>Kata Pengantar</b>
	<p>Kata kata kataKata kata kataKata kata kataKata 
	kata kataKata kata kataKata kata kataKata kata kataKata kata 
	kataKata kata kataKata kata kataKata kata kataKata kata kataKata kata 
	kataKata kata kataKata kata kataKata kata kataKata kata kataKata kata kata</p>
	<p>Kata kata kataKata kata kataKata kata kataKata 
	kata kataKata kata kataKata kata kataKata kata kataKata kata 
	kataKata kata kataKata kata kataKata kata kataKata kata kataKata kata 
	kataKata kata kataKata kata kataKata kata kataKata kata kataKata kata kata</p>
	<p>Kata kata kataKata kata kataKata kata kataKata 
	kata kataKata kata kataKata kata kataKata kata kataKata kata 
	kataKata kata kataKata kata kataKata kata kataKata kata kataKata kata 
	kataKata kata kataKata kata kataKata kata kataKata kata kataKata kata kata</p>
</page>
<page pageset="old">
	<bookmark title="Daftar Isi" level="0" ></bookmark> 
</page>
<page pageset="old">
	<bookmark title="Data pribadi" level="0" ></bookmark>
	<?php
	
$profil = my_get_data_by_id('peserta_mcu','no_mcu',$_SESSION['no_mcu'] );
	?>
	<table style="width: 100%;" align="center">
		<tr>
			<td style="vertical-align: top; padding: 2px; width: 30%; text-align: left;"><b>NAMA</b> </td>
			<td style="vertical-align: top; padding: 2px; width: 70%; text-align: left;">: <?php echo $profil['nama_mcu']; ?>  </td>
		</tr>
		<tr>
			<td style="vertical-align: top; padding: 2px; width: 30%; text-align: left;"><b>UMUR</b></td>
			<td style="vertical-align: top; padding: 2px; width: 70%; text-align: left;">: <?php if(trim($profil['tanggal_lahir'] ) <> '') echo (date('Y') - date('Y' , strtotime($profil['tanggal_lahir'] ." 00:00:00") )); else echo "-"; ?></td>
		</tr>
		<tr>
			<td style="vertical-align: top; padding: 2px; width: 30%; text-align: left;"><b>PERUSAHAAN</b></td>
			<td style="vertical-align: top; padding: 2px; width: 70%; text-align: left;">: <?php if(trim($profil['nama_pt'] ) <> '') echo strtoupper($profil['nama_pt']); else echo "-";?></td>
		</tr>
	</table>
	<table style="width: 100%;border: solid 1px #000000" align="center">
		<tr>
			<td style="vertical-align: top; padding: 2px; width: 50%; text-align: left; border: solid 1px #000000"><i>Jabatan:</i><br><?php if(trim($profil['nm_bagian'] ) <> '')echo strtoupper($profil['nm_bagian']); else echo "-";?><br></td>
			<td style="vertical-align: top; padding: 2px; width: 50%; text-align: left; border: solid 1px #000000"><i>NIK</i><br><?php if(trim($profil['nik'] ) <> '') echo strtoupper($profil['nik']);else echo "-"; ?><br></td>
		</tr>
		<tr>
			<td style="vertical-align: top; padding: 2px; width: 50%; text-align: left; border: solid 1px #000000"><i>Divisi</i><br><?php if(trim($profil['nm_devisi'] ) <> '') echo strtoupper($profil['nm_devisi']); else echo "-";?><br></td>
			<td style="vertical-align: top; padding: 2px; width: 50%; text-align: left; border: solid 1px #000000"><i>Tanggal periksa</i><br><?php if(trim($profil['tanggal'] ) <> '')echo strtoupper($profil['tanggal']); else echo "-";?><br></td>
		</tr>
	</table>	
	<br><br>
	<bookmark title="Riwayat kesehatan keluarga" level="0" ></bookmark>	
	<div class="note">
		Riwayat kesehatan keluarga :<br>
	</div>
	<br> 
	<?php 
	print( laporan_riwayat_keluarga_cetak() );
	?>
</page>
<page pageset="old">
	<bookmark title="Riwayat kesehatan pribadi" level="0" ></bookmark>	
	<bookmark title="Penyakit yang pernah/sedang diderita" level="1" ></bookmark>	
	<div class="note">
		Penyakit yang pernah/sedang diderita :<br>
	</div>
	<br> 
	<?php 
	print( laporan_riwayat_ask_list() );
	?>
</page>
<page pageset="old"> 
	<bookmark title="Gejala yang dialami sekarang" level="1" ></bookmark>	
	<div class="note">
		Gejala yang dialami sekarang :<br>
	</div>
	<br> 
	<?php 
	print( laporan_gejala_ask_list() );
	?>
	<div class="note">
		Keluhan lainnya :<br>
	</div> 
	&nbsp; &nbsp; Tidak ada keluhan lain
	 
</page>
<page pageset="old"> 
	<bookmark title="Nyeri dada" level="1" ></bookmark>	 
	<div class="note">
		Nyeri dada :<br>
	</div>
	<br> 
	<?php 
	print( laporan_nyeri_dada() );
	?>  
	<bookmark title="Hambatan aktifitas fisik" level="1" ></bookmark>	
	<div class="note">
		Hambatan aktifitas fisik :<br>
	</div>
	<br> 
	<?php 
	print( laporan_hambatan_aktifitas_fisik() );
	?>  
	<bookmark title="Aktifitas fisik" level="1" ></bookmark>	
	<div class="note">
		Aktifitas fisik :<br>
	</div>
	<br> 
	<?php 
	print( laporan_aktifitas_fisik() );
	?>  
</page>
<page pageset="old">
	<bookmark title="Kebiasaan makan" level="1" ></bookmark>	
	<div class="note">
		Kebiasaan makan :<br>
	</div>
	<br> 
	<?php 
	print( laporan_kebiasaan_makan() );
	?>
</page>

<page pageset="old">
	<bookmark title="Mengatasi stress" level="1" ></bookmark>	
	<div class="note">
		Mengatasi stress :<br>
	</div>
	<br> 
	<?php 
	print( stress_report() );
	?>
	<bookmark title="Perasaan 4 minggu terakhir" level="1" ></bookmark>	
	<div class="note">
		Perasaan 4 minggu terakhir :<br>
	</div>
	<br> 
	<?php 
	print( laporan_perasaan_akhir() );
	?>
	<bookmark title="Hobi dan kebiasaan" level="1" ></bookmark>	
	<div class="note">
		Hobi dan kebiasaan :<br>
	</div>
	<br> 
	<?php 
	print( laporan_hobby() );
	?>  	
</page>

<page pageset="old">
	<bookmark title="Riwayat kerja" level="0" ></bookmark>	
	<div class="note">
		Riwayat kerja :<br>
	</div>
	<br> 
	<?php 
	print( laporan_riwayat_kerja() );
	?> 
</page>
<page pageset="old">
	<bookmark title="Hasil-hasil pemeriksaaan" level="0" ></bookmark>
	<bookmark title="Pemeriksaan antropometri" level="1" ></bookmark>	
	<div class="note">
		Pemeriksaan antropometri :<br>
	</div>
	<br> 
	 
	<?php 
	print( antropometri_form_detail() );
	?>  	
</page>
<page pageset="old"> 
	<bookmark title="Pemeriksaan fisik" level="1" ></bookmark>	
	<div class="note">
		Pemeriksaan fisik :<br>
	</div>
	<br> 
	 
	<?php 
	print( fisik_form_detail( )  );
	?>  	
</page>
<page pageset="old"> 
	<bookmark title="Pemeriksaan radiologi" level="1" ></bookmark>	
	<div class="note">
		Pemeriksaan radiologi :<br>
	</div>
	<br> 
	 
	<?php 
	print( radiologi_form_detail( )  );
	?>  	
</page>
<page pageset="old"> 
	<bookmark title="Pemeriksaan kardiologi" level="1" ></bookmark>	
	<div class="note">
		Pemeriksaan kardiologi :<br>
	</div>
	<br> 
	 
	<?php 
	print( kardiologi_form_detail( )  );
	?>  	
</page>
<page pageset="old"> 
	<bookmark title="Pemeriksaan T H T" level="1" ></bookmark>	
	<div class="note">
		Pemeriksaan T H T :<br>
	</div>
	<br> 
	 
	<?php 
	print( tht_form_detail( ) );
	?>  	
</page>
<page pageset="old"> 
	<bookmark title="Pemeriksaan audiometri" level="1" ></bookmark>	
	<div class="note">
		Pemeriksaan Audiometri :<br>
	</div>
	<br> 
	 
	<?php 
	print( audiometri_form_report( ) );
	?>  	
</page>
<page pageset="old"> 
	<bookmark title="Pemeriksaan paru" level="1" ></bookmark>	
	<div class="note">
		Pemeriksaan paru :<br>
	</div>
	<br> 
	 
	<?php 
	print( paru_form_detail( ) );
	?>  	
</page>
<page pageset="old"> 
	<bookmark title="Pemeriksaan mata" level="1" ></bookmark>	
	<div class="note">
		Pemeriksaan mata :<br>
	</div>
	<br> 
	 
	<?php 
	print( mata_form_detail( ) );
	?>  	
</page>
<page pageset="old"> 
	<bookmark title="Pemeriksaan neurologi" level="1" ></bookmark>	
	<div class="note">
		Pemeriksaan neurologi :<br>
	</div>
	<br> 
	 
	<?php 
	print( neurologi_form_detail( )  );
	?>  	
</page>
<page pageset="old"> 
	<bookmark title="Hasil uji kesehatan" level="0" ></bookmark>
	<bookmark title="Kesimpulan klinis" level="1" ></bookmark>	
	<div class="note">
		Kesimpulan klinis :<br>
	</div>
	<br> 
	 
	<?php 
	print( laporan_kesimpulan_klinis( )  );
	?>  	
 
	<bookmark title="Kesimpulan kedokteran okupasi" level="1" ></bookmark>	
	<div class="note">
		Kesimpulan kedokteran okupasi :<br>
	</div>
	<br> 
	 
	<?php 
	print(  kesimpulan_okupasi( )  );
	?>  	
</page>